<template>
	<view>
		<view class="container">
			<text  class="text-lg">修改密码</text>
			<view class="row input-phone" style="">
				<zywork-icon type="icon-shouji" size="40" color="#919191"></zywork-icon>
				<text class="text-base" style="margin-left: 15rpx;">+86</text>
				<input style="margin-left: 15rpx;" disabled placeholder="请输入手机号" type="number" v-model="userInfo.phonenumber" pattern="[0-9]*"/>
			</view>
			<view class="row input-phone" style="">
				<zywork-icon type="icon-mima" size="40" color="#919191"></zywork-icon>
				<input style="margin-left: 15rpx;" password  placeholder="请输入原密码" v-model="oldPassword" />
			</view>
			<view  class="row input-phone" style="">
				<zywork-icon type="icon-psw-reset" size="40" color="#919191"></zywork-icon>
				<input style="margin-left: 15rpx;width: 70%;" password  placeholder="输入新密码(8-20位数字和字母)" v-model="password" />
			</view>
			<view  class="row input-phone" style="">
				<zywork-icon type="icon-querenmima" size="40" color="#919191"></zywork-icon>
				<input style="margin-left: 15rpx;width: 70%;" password  placeholder="确认新密码(8-20位数字和字母)"  v-model="ConfirmPassword" />
			</view>
			<!-- <view class="row" style="margin-top: 30rpx;">
				<text style="margin-left: auto;" class="font-color" @click="retrievePassword">找回密码</text>
			</view> -->
			<view @click="submit" class="login-button text-base" style="font-weight: 800;margin-top: 100rpx;">
				完成
			</view>	
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				heightTop:10,
				getCodeText:"获取验证码",
				userInfo:"",
				oldPassword:"",//原密码
				password:"",//新密码
				ConfirmPassword:""
			};
		},
		created() {
			this.heightTop += uni.getSystemInfoSync().statusBarHeight
		},
		onShow() {
			this.userInfo = uni.getStorageSync(this.$util.USER_INFO)
		},
		methods:{
			submit(){
				if(!this.oldPassword){
					this.$util.showInfoToast("请输入原密码")
					return
				}
				if(!this.password){
					this.$util.showInfoToast("请输入新密码")
					return
				}
				if(!this.ConfirmPassword){
					this.$util.showInfoToast("请输入确认新密码")
					return
				}
				if(this.password != this.ConfirmPassword){
					this.$util.showInfoToast("两次输入密码不一致，请重新输入")
					return
				}
				this.$util.doPostJson('/user/modifypasswod', {
					oldPassword:this.oldPassword,
					password:this.password
				}, {}, true).then(res => {
					if(res.data.code == this.$ResponseStatus.OK){
						this.$util.showInfoToast(res.data.message)
						this.$util.showSuccessToast("修改成功")
						setTimeout(()=>{
							uni.navigateBack({})
						},2000)
					}
				}).catch(error => {
					console.log(error)
				})
			},
			retrievePassword(){
				uni.navigateTo({
					url:"/pages/login/retrieve-password?state=1"
				})
			},
		},
		beforeDestroy() {
			this.time
		}
	}
</script>

<style lang="scss">
	
	.font-color{
		color: #6BA9D7;
	}
	
	.font-color1{
		color: #919191;
	}
	
	.container{
		padding: 30rpx 50rpx;
		margin-top: 50rpx;
		.input-phone{
			padding: 15rpx 0rpx;
			border-bottom: solid 1rpx #eeeeee;
			align-items: center;
			margin-top: 76rpx;
		}
		
		.login-button{
			flex: 1;
			background-color: #eee;
			color: #919191;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			border-radius: 50rpx;
			margin-top: 50rpx;
		}
		
	}
	
	.text-lg{
		font-size: 48rpx;
	}
	
	.text-base{
		font-size: 34rpx;
	}
	
	
	
</style>
